{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.简述仿射变换和透视变换的基本概念，并用实例说明。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：\n",
    "仿射变换是把二维的图像进行旋转，平移和比例缩放等几何变换，比如将一组平行线或其他二维图形进行旋转、平移或比例缩放的这种变换就是仿射变换。\n",
    "透视变换是把物体的三维图像转化为二维图像表示的过程。透视变换的实例：公路两边平行的护栏经过人眼的透视变换后在远方相交于一点。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. 结合图简述图像坐标系、相机坐标系和世界坐标系的定义，并说明三者之间的变换关系。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：图像坐标系是是二维的，描述图像的坐标系，通常原点在相机感光元件的中心。相机坐标系通常以相机的镜头为坐标原点，建立在相机机身上的坐标系。世界坐标系要根据具体问题来判断建立在什么地方，通常是建立在绝对静止的研究物体上。\n",
    "相机坐标系和世界坐标系的变换关系如下：\n",
    "![image][base64str]\n",
    "在这个公式中，R为3*3矩阵，T为3*1，0为（0，0，0），简化用Lw表示后为4*4矩阵。\n",
    "\n",
    "相机坐标系和图像坐标系的示意图关系如下：\n",
    "![image][image1]\n",
    "\n",
    "相机坐标系和图像坐标系的关系如下：\n",
    "![image][image2]\n",
    "\n",
    "\n",
    "\n",
    "[base64str]:\n",
    "\n",
    "[image1]:\n",
    "\n",
    "[image2]:\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.什么是相机的内、外参数矩阵？实际中你能结合身边的实例(如电脑摄像头、手机镜头)说明这些参数的大致值么？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：\n",
    "内参数矩阵如下：\n",
    "![image][内参]\n",
    "\n",
    "外参数矩阵如下：\n",
    "![image][外参]\n",
    "\n",
    "下面计算手机摄像头的内参：\n",
    "网上查到华为P30手机镜头最高分辨率7296 × 5472，传感器尺寸：7.53mm * 5.65mm。拍照显示焦距为27mm\n",
    "先计算x方向：\n",
    "u_0 = 7296 / 2 = 3648\n",
    "d_x = 7.53 / 7296 = 0.001032\n",
    "f_x = f / d_x = 27 / 0.001032 = 26162.79\n",
    "\n",
    "再计算y方向：\n",
    "v_0 = 5472 / 2 = 2736\n",
    "d_y = 5.65 / 5472 = 0.001033\n",
    "f_y = f / d_y = 27 / 0.001033 = 26137.46\n",
    "\n",
    "算出的数值感觉不对，怀疑是不是最高分辨率的问题。拍了十张棋盘格的照片发现分辨率均为3648 × 2736, 用这个数试一下：\n",
    "先计算x方向：\n",
    "u_0 = 3648 / 2 = 1824\n",
    "d_x = 7.53 / 3648 = 0.002064\n",
    "f_x = f / d_x = 27 / 0.002064 = 13081.39\n",
    "\n",
    "再计算y方向：\n",
    "v_0 = 2736 / 2 = 1368\n",
    "d_y = 5.65 / 2736 = 0.002065\n",
    "f_y = f / d_y = 27 / 0.002065 = 13075.60\n",
    "\n",
    "算出来的结果还是有问题，怀疑可能是传感器\n",
    "\n",
    "[内参]:\n",
    "\n",
    "[外参]:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4. 说明使用线性法求解相对位姿时的要求输入和输出，以及求解的基本思想。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：线性求解的输入是相机内参数，多个平面上的特征点在目标坐标系（3D）和像平面坐标系（2D）的坐标；线性求解的输出是目标坐标系相对相机坐标系的位置和姿态。\n",
    "求解的基本思想：通过相机标定或者相机自身参数计算获取内参数和畸变系数，再建立世界坐标系转换为像素坐标系的方程：目的是求解外参数矩阵的旋转向量和平移向量；通过方程组的变换，得到一个关于旋转向量和平移向量的公式。根据这个公式，在有四个或以上的非共面特征点时，就能够解该方程组。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. 说明使用Zhang方法进行相机标定需要的输入条件和得到的具体输出量，以及Zhang方法的主要步骤"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答： 输入条件是一个平面靶标的多个位置和姿态，输出位相机的内参，外参以及畸变参数。该方法的主要步骤是：\n",
    "1. 对一个pose，计算单应矩阵（类似M矩阵）\n",
    "2. 有三个以上pose，根据各单应矩阵计算线性相机参数\n",
    "3. 使用非线性优化方法计算非线性参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
